import Vue from 'vue';
import Router from 'vue-router';
const _import = require('./_import_' + process.env.NODE_ENV);
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading

/* layout */
import Layout from '../views/layout/Layout';

/* login */
const Login = _import('login/login');
// const Login = _import('login/forgetPwd');

/* forgetPwd */
const ForgetPwd = _import('login/forgetPwd');

const SendEmail = _import('login/sendEmail');

const BackPwd = _import('login/backPwd');

const ResetPwd = _import('login/resetPwd');

const ResetPwdSucess = _import('login/resetPwdSucess');


/* dashboard */
const dashboard = _import('dashboard/index');

/* error page */
const Err404 = _import('404');


const Table = _import('table/index');
/* 企业管理 */
const Enterprise = _import('system/enterprise');
/* 账号组管理 */
const AccountGroup = _import('system/accountGroup');
/* 数据字典 */
const DataDictionary = _import('system/dataDictionary');
/* 菜单管理 */
const Menumanage = _import('system/menu');
/* 个人中心 */
const UserCenter = _import('system/userCenter');
/* 机房管理 */
const EptRoomanage = _import('system/eptroom');
/* 角色管理 */
const Rolemanage = _import('system/role');
const Account = _import('system/account');

/* 机柜管理 */
const cabinetManage = _import('resource/cabinetManage');
/* 设备管理 */
const equipManage = _import('resource/equipManage');
/* 报修记录 */
const repairRecord = _import('resource/repairRecord');
/* 基础数据 */
const database = _import('resource/database');
/* 宿主机信息 */
const hostInfo = _import('resource/hostInfo');
/* 网络资源管理 */
const nrManage = _import('resource/netResource');

Vue.use(Router);

 /**
  * icon : the icon show in the sidebar
  * hidden : if `hidden:true` will not show in the sidebar
  * redirect : if `redirect:noredirect` will not redirct in the levelbar
  * noDropdown : if `noDropdown:true` will not has submenu in the sidebar
  * meta : `{ role: ['admin'] }`  will control the page role
  **/
export const constantRouterMap = [
  { path: '/login', component: Login, hidden: true },
  { path: '/forgetPwd', component: ForgetPwd, hidden: true },
  { path: '/sendEmail', component: SendEmail, hidden: true },
  { path: '/backPwd', component: BackPwd, hidden: true },
   { path: '/resetPwd', component: ResetPwd, hidden: true },
   { path: '/resetPwdSucess', component: ResetPwdSucess, hidden: true },
  { path: '/404', component: Err404, hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Home',
    hidden: true,
    children: [{ path: 'dashboard', component: dashboard }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
});

export const asyncRouterMap = [
  {
    path: '/system',
    component: Layout,
    redirect: 'noredirect',
    name: '系统管理',
    icon: 'zujian',
    children: [
      { path: 'enterprise', component: Enterprise, name: '企业管理' },
      { path: 'role', component: Rolemanage, name: '角色管理' },
      { path: 'accountGroup', component: AccountGroup, name: '账号组管理' },
      { path: 'account', component: Account, name: '账号管理' },
      { path: 'eptroom', component: EptRoomanage, name: '机房管理' },
      { path: 'menu', component: Menumanage, name: '菜单管理' },
      { path: 'userCenter', component: UserCenter, name: '个人中心' },
      { path: 'dataDictionary', component: DataDictionary, name: '数据字典' },
		
    ]
  },
  {
    path: '/resource',
    component: Layout,
    redirect: 'noredirect',
    name: '资源管理',
    icon: 'zonghe',
    children: [
      { path: 'cabinetManage', component: cabinetManage, name: '机柜管理' },
      { path: 'equipManage', component: equipManage, name: '设备管理' },
      { path: 'repairRecord', component: repairRecord, name: '报修记录' },
      { path: 'database', component: database, name: '基础数据管理' },
      { path: 'hostInfo', component: hostInfo, name: '宿主机信息' },
      { path: 'nrManage', component: nrManage, name: '网络资源管理' }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }

];
